﻿<%
Dim MenuID			
Dim MenuName
Dim MenuVisibled
Dim Menu_Order
Sub Admin_Menu_Add()	

	
	MenuName = reform("MenuName")
	Call Check_Length(MenuName,100,1,"菜单名称")

	Menu_Order = Get_Max_Order(ParentID)
	MenuVisibled = "1"

	sql = "INSERT INTO Admin_Menu(MenuName,MenuVisibled,Menu_Order ) VALUES( " &_
		  "'" & MenuName & "'"&_
		  ",'" & MenuVisibled & "'"&_
		  "," & Menu_Order & ")" 

    conn.execute(sql)

	AlertBox "菜单增加成功！","Admin_Menu_Query.asp"


End Sub

Sub Admin_Menu_Edit()	
	MenuID	 = reform("MenuID")
	MenuName = reform("MenuName")
	MenuVisibled = reform("MenuVisibled")

	Call Check_Isnumeric_Msg(MenuID,"菜单ID")
	Call Check_Isnumeric_Msg(MenuVisibled,"菜单ID")
	Call Check_Length(MenuName,100,1,"菜单名称")

	sql = "UPDATE Admin_Menu Set " &_
		  " MenuName = '" & MenuName & "'" &_
		  ",MenuVisibled = " & MenuVisibled &_
		  " WHERE MenuID = "&MenuID


    conn.execute(sql)

	AlertBox "菜单修改成功！","Admin_Menu_Query.asp"

End Sub

Sub Admin_Menu_Del()


	MenuID = Reform("Op_ID")	


	sql = "DELETE FROM  Admin_Menu WHERE MenuID IN  ("&MenuID &")"&_
		  ";DELETE  FROM  Admin_Menu WHERE ParentID IN  ("&MenuID &")" '下级菜单也一起删除
	On Error Resume Next
		  
    conn.execute(sql)

	if err.number =0 then  
		AlertBox "菜单删除成功！","Admin_Menu_Query.asp"
	else 
		AlertBox "菜单删除失败！","Admin_Menu_Query.asp"
	end if


	
End Sub

Function Get_Max_Order(ParentID)
	Get_Max_Order = conn.execute("SELECT ISNULL(MAX(Menu_Order),0)+5 FROM Admin_Menu WHERE ParentID=0")(0)
End Function 

Sub Get_Admin_Menu_Info(MenuID)


	sql = "SELECT * FROM Admin_Menu WHERE MenuID = " &MenuID

	Set rs = conn.execute(sql)
	
	If Not rs.eof Then

		MenuID   = rs("MenuID")
		MenuName = rs("MenuName")
		MenuVisibled = rs("MenuVisibled")
		
	End If
	

End Sub 
%>

